# Install hook code here
require 'ftools'
require 'fileutils'

plugins_dir = File.expand_path(".")
saucy_dir = File.join(plugins_dir, 'saucy')
root_dir = File.join(saucy_dir, '..', '..', '..')

puts "\n\nInstalling Saucy Plugin for Rails\n\n"

#puts "making directory RAILS_ROOT/public/javascripts/saucy"
#FileUtils.mkdir File.join(root_dir, 'public', 'javascripts', 'saucy') rescue puts "... failed making dir, directory may already exist."

puts "copying ./lib/javascripts to RAILS_ROOT/public/javascripts"
File.copy File.join(saucy_dir, 'javascripts', 'jquery.js'), File.join(root_dir, 'public', 'javascripts')
File.copy File.join(saucy_dir, 'javascripts', 'base64.js'), File.join(root_dir, 'public', 'javascripts')
File.copy File.join(saucy_dir, 'javascripts', 'saucy.js'), File.join(root_dir, 'public', 'javascripts')
puts "copying ./saucy_test_pages to RAILS_ROOT/public"
File.copy File.join(saucy_dir, 'saucy.html'), File.join(root_dir, 'public')
puts "copying ./lib/saucy.rb to RAILS_ROOT/app/models"
File.copy File.join(saucy_dir, 'lib', 'saucy.rb'), File.join(root_dir, 'app', 'models')
puts "copying ./lib/saucy_styles.rb to RAILS_ROOT/app/models"
File.copy File.join(saucy_dir, 'lib', 'saucy_styles.rb'), File.join(root_dir, 'app', 'models')
puts "copying ./lib/saucy_contrpller  to RAILS_ROOT/app/controllers"
File.copy File.join(saucy_dir, 'lib', 'saucy_controller.rb'), File.join(root_dir, 'app', 'controllers')
puts "making directory RAILS_ROOT/public/images/saucy"
FileUtils.mkdir File.join(root_dir, 'public', 'images', 'saucy') rescue puts "... failed making dir, directory may already exist."
puts "installation complete...\n\n"

puts IO.read(File.join(File.dirname(__FILE__), 'README'))
